var express = require('express');
var https = require('https');
var http = require('http');

var routes = require('./route.js');
var app = express();
var expressConfig = require('./expressConfig.js');

var config = expressConfig.config();
//const hostname = config.hostname;
const port = config.port;
const baseDir = __dirname;


app.use('/js',express.static(baseDir + '/js'));
app.use('/css',express.static(baseDir + '/css'));
app.use(express.static(baseDir + '/view'));

routes.route(app);

var server = app.listen(port, function () {
    console.log('Express Example app listening run');
});

//app的locals属性
app.locals.title = 'test'
console.info(app.locals.title)

//路由多级挂载
var admin = express();
admin.get('/', function (req, res) {
  console.log(admin.mountpath); // [ '/adm*n', '/manager' ]
  res.send('Admin Homepage');
})

var secret = express();
secret.get('/', function (req, res) {
  console.log(secret.mountpath); // /secr*t
  res.send('Admin Secret');
});

admin.use('/secr*t', secret);
app.use(['/adm*n', '/manager'], admin); 